package com.isp.aut.server.service;

import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached;
import com.isp.aut.server.reference.ResourceReference;
import com.isp.common.model.user.PermissionDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class PermissionService {

    private final ResourceReference resourceReference;


    @Cached(name = "permission4Group::", key = "#permissionDTO.groupCode", cacheType = CacheType.BOTH, expire = 5)
    //在一个JVM中，同一个键只有一个线程加载，其他线程等待结果。
//    @CachePenetrationProtect
    public List<PermissionDTO> queryPermissionsByGroupCode(PermissionDTO permissionDTO) {
        return resourceReference.permissions(permissionDTO).getData();
    }

}
